/*
 * serialLedSolution.c
 *
 * Created: 10/14/2013 4:34:20 AM
 *  Author: Tim
 */ 

#include "../src/Epiphany.h"

uint8_t byte;

void setup()
{
	clockInit();
	usbInit(115200);
	RTC_DelayInit();
	dbledInit();
	sei();	
}


void loop()
{
	if(dataInBufUSB())
	{
		fscanf(&USB_str,"%c",&byte);	//read a character (denoted by %c) from the USB stream, and store it at the address of (address of = &) the variable byte
		
		if		(byte == '1') 
		{
			dbledOn();
			fprintf(&USB_str,"led on\r\n");
		}
		else if (byte == '0') 
		{
			dbledOff();
			fprintf(&USB_str,"led off\r\n");
		}
	}
}